package com.home.simple.service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.home.simple.model.Person;
import com.home.simple.model.Reservation;

public class ReservationServiceImpl implements ReservationService {

	private List<Reservation> reservationList = new ArrayList<Reservation>();
	
	public ReservationServiceImpl(){
		Person p1 = new Person("erdem", "1");
		Person p2 = new Person("gokce", "2");
		Person p3 = new Person("oya", "3");
		Person p4 = new Person("brak", "4");
		
		List<Person> reservation1People = new ArrayList<Person>();
		reservation1People.add(p1);
		reservation1People.add(p2);
		
		List<Person> reservation2People = new ArrayList<Person>();
		reservation2People.add(p3);
		reservation2People.add(p4);
		
		reservationList.add(new Reservation(1, "court1", reservation1People, new Date()));
		reservationList.add(new Reservation(2, "court2", reservation2People, new Date()));
	}
	
	@Override
	public List<Reservation> getReservations(String courtName) {
		List<Reservation> reservations = new ArrayList<Reservation>();
		
		for (Reservation reservation : reservationList) {
			if(reservation.getCourtName().equals(courtName)){
				reservations.add(reservation);
			}
		}
		return reservations;
	}

}
